<?php
//header("Content-Type: text/html; charset=UTF-8");
include "config.php";
include "util/functions.php";
$SELECTED_MENU="menu-3";

session_start();
$mylink = mySqlOpen($mySQLserver, $mySQLuser, $mySQLpassword, $mySQLdefaultdb);


$page = $_REQUEST['page'];
$page = ($page) ? $page : 0;
$portfolios = getUserPortfolios($page);
$allPortfoliosCount = getUserPortfoliosCount();
$maxPageCount = $allPortfoliosCount / $GLOBALS['PORTFOLIOS_PAGE_SIZE'];

mySqlClose($mylink);

?>

<html>
<head>
<title>ООО "СитиМолПроект" - Современные технологии строительства и проэктирования - Портфолио</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta content="Современные технологии строительства и проектирования: новости, портфолио" name="description">
<meta content="строительство, проектирование, портфолио, новости" name="keywords">
<link href="css/style.css" type="text/css" rel="stylesheet">

    <link rel="stylesheet" type="text/css" href="css/funcy.css" media="screen">

    <script src="js/Event.js" language="javascript"></script>
    <script src="js/modificatMenu.js" language="javascript"></script>
    <script src="js/resize.js" language="javascript"></script>

    <script type="text/javascript" src="js/jquery-1.js"></script>
    <script type="text/javascript" src="js/jquery.js"></script>
    <script type="text/javascript" src="js/jquery_002.js"></script>

    <script type="text/javascript">
        $(document).ready(function() {
            $("a.gallery, a.iframe").fancybox();
            $("a.iframe").fancybox(
            {
                "frameWidth" : 800,   // ширина окна, px (425px - по умолчанию)
                "frameHeight" : 600 // высота окна, px(355px - по умолчанию)

            });


        });
    </script>

</head>
<body>
<center>
<table width="1004" border="0">
	<tbody><tr>
		<td colspan="4">
		</td>
	</tr>
	<tr>
		<td colspan="4">
			<table width="1004"><tbody><tr height="1"><td width="1004" bgcolor="#244aa7"></td></tr></tbody></table>
		</td>
	</tr>
	<tr>
		<td colspan="4">
            <?php
            include "header.php";
            ?>
		</td>
	</tr>
	<tr>
		<td colspan="4">
            <?php
            include "main_menu.php";
            ?>
		</td>
	</tr>
	<tr>
		<td style="height: 100%;  " width="208">
            <?php
            include "left_menu.php";
            ?>
		</td>
		<td width="795">
			<table class="main">
				<tbody>
				<tr>
					<td width="790">
						<table class="headermain">
							<tbody><tr>
								<td width="28"><img src="img/w_small3.jpg"></td>
								<td width="116">Портфолио</td>
								<td width="2"></td>
							</tr>
						</tbody></table>

                        <table class="portfolio" border="0">
                        <?php
                        $cnt = 0;
                        $cellsInRow = 4;
                        foreach ($portfolios as $key => $portfolio) {
                            if ($cnt == 0) {
                                ?>
                            <tr>
                                <?php
                            }
                            include "portfolio_item.php";
                            $cnt++;
                            if ($cnt == $cellsInRow) {
                                $cnt = 0;
                                ?>
                            </tr>
                                <?php
                            }
                        }
                        if ($cnt > 0) {
                            for ($i = $cnt; $i < $cellsInRow; $i++) {
                                ?>
                                <td></td>
                                <?php
                            }
                                ?>
                            </tr>
                                <?php
                        }
                        ?>
                        </table>



                        <table class="headermain">
                            <tbody>
                            <tr>
                                <td width="600">
                        <?php   if ($page > 0) { ?>
                                        <a href="?page=<?php print ($page - 1); ?>">
                                            <button><< PREV <?php print $GLOBALS['PORTFOLIOS_PAGE_SIZE'] ?></button>
                                        </a>
                        <?php   }   ?>
                        <?php   if ($page < $maxPageCount - 1) { ?>
                                        <a href="?page=<?php print ($page + 1); ?>">
                                            <button>NEXT <?php print $GLOBALS['PORTFOLIOS_PAGE_SIZE'] ?> >></button>
                                        </a>
                        <?php   }   ?>

                                </td>
                            </tr>
                            </tbody>
                        </table>
					</td>
				</tr>
			</tbody></table>
		</td>
		<td width="1" bgcolor="#b2b2b2">
		</td>
		<td width="0">
		</td>

	</tr>
	<tr>
		<td colspan="4">
            <?php
            include "footer.php";
            ?>
		</td>
	</tr>
</tbody></table>
</center>

</body></html>